public class StringClass {

    public final double PER = 0.3;
    public final String mommy = "mommy";
    public boolean percentageOfVowelsInStringIsMoreThanThirty(String str) {
        int countVowel = 0;
        for (int i = 0; i < str.length(); i++) {
            if (isVowel(str.charAt(i)))
                countVowel++;
        }
        if (countVowel > str.length() * PER)
            return true;
        else
            return false;
    }

    public String returnModifiedString(String str) {
        String modifiedString = "";

        if (percentageOfVowelsInStringIsMoreThanThirty(str)) {
            for (int i = 0; i < str.length(); i++) {
                if (isVowel(str.charAt(i))) {
                    while (i < str.length() && isVowel(str.charAt(i))) {
                        i++;
                    }
                    i--;

                    modifiedString += mommy;
                } else
                    modifiedString += str.charAt(i);
            }
        }

        return modifiedString;
    }

    public boolean isVowel(char ch) {
        if ((ch == 'a') || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
            return true;
        } else return false;
    }
}
